﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu
{
    public partial class FrmListBloco : Form
    {
        private BlocoBL bl  = new BlocoBL();

        public FrmListBloco()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadBloco c = new FrmCadBloco(bl);
            c.ShowDialog();
            blocoBindingSource.DataSource = bl.selecionar();
        }

        private void FrmListBloco_Load(object sender, EventArgs e)
        {
            blocoBindingSource.DataSource = bl.selecionar();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
          //  pnlFundo.Dock = DockStyle.Fill;
            pnlFundo.Visible = true;
          //  toolStrip1.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
          //  pnlFundo.Dock = DockStyle.None;
            pnlFundo.Visible = false;
            //toolStrip1.Visible = true;

            blocoBindingSource.DataSource = bl.selecionar(txtDesc.Text);
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
           // pnlFundo.Dock = DockStyle.None;
            pnlFundo.Visible = false;
           // toolStrip1.Visible = true;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadBloco c = new FrmCadBloco(bl, ((bloco)blocoBindingSource.Current) );
            c.ShowDialog();
            blocoBindingSource.DataSource = bl.selecionar();
        }

        private void dtGrdVwBloco_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
                toolStripButton2_Click(null, new EventArgs());
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {                
                bl.excluir((bloco)blocoBindingSource.Current);
                blocoBindingSource.DataSource = bl.selecionar();
            }
        }
    }
}
